package online.shenjian.kafka;

import lombok.Data;

@Data
public class TotalAndCount {
  private Double total;
  private Long count;

  public TotalAndCount() {}

  public TotalAndCount(Double total, Long count) {
    this.total = total;
    this.count = count;
  }

  public TotalAndCount add(Double amount) {
    return new TotalAndCount(total + amount, count + 1);
  }

  public double getAvg() {
    return total / count;
  }
}

